package com.eschool.exception;

import com.eschool.pojo.ServerResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class langchain_EschoolException {

    @ExceptionHandler
    public ServerResult exceptionHandler(Throwable e){
        String message = e.getMessage();
        //保存到数据库,通过网页显示异常，判断异常的等级
        e.printStackTrace();//把异常打印到控制台
        //返回错误信息给前端
        ServerResult serverResult = new ServerResult(500, "服务器出错,到控制台查看错误详细信息!", message);
        return serverResult;
    }
}
